var app = getApp()

Page({

  data: {
    type: '',
  },

  onLoad: function (options) {
    if (options.type) {
      this.setData({
        type: options.type
      })
    }
  },

  onShareAppMessage: function () {
    var that = this
    return {
      title: '创作属于你的艺术!',
      imageUrl: '/images/share.jpg',
      path: '/pages/index/index',
      complete: function (res) {
        console.log('unlock share complete')
        wx.request({
          url: app.globalData.url + 'share_callback/openid/' + app.globalData.openId,
          complete: function (res) {
            app.globalData.level = res.data.data
            wx.redirectTo({
              url: '/pages/middle/middle?type=' + that.data.type,
            })
          }
        })
      },
    }
  },

  goback: function () {
    wx.redirectTo({
      url: '/pages/middle/middle?type=' + this.data.type,
    })
  }
})